From 1b3c9214371d89a4872574d700b86cb71d6eee56 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 4 Jun 2001 23:15:51 +0000 Subject: [PATCH] Handle case where we need to parse the xsetting as if it were an RC file 2001-05-10 Havoc Pennington * gtk/gtksettings.c (gtk_settings_get_property): Handle case where we need to parse the xsetting as if it were an RC file string. * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial value of palette from settings, not from static variable * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to xsettings translation table * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because hardcoding the toolbar style conflicts with new customizable toolbar style philosophy (gtk_toolbar_class_init): add settings for default toolbar style; these are used unless the app specifically forces a toolbar style * gtk/gtksettings.c (settings_install_property_parser): only return at the start if we warn and parser == NULL * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the palette changed handler so we don't notify dead color selections * gtk/gtkstyle.c (gtk_default_draw_shadow): handle xthickness/ythickness of 0 or 1 properly (gtk_default_draw_resize_grip): clear the background behind the resize grips, and align to bottom right if we square the area to be drawn. * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on statusbar label to 1, so it doesn't make toplevels resize oddly (gtk_statusbar_size_request): add grip size to request (gtk_statusbar_size_allocate): hack so the hbox still works with the grip size in the request * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix bug where showing all on a toplevel makes the toolbar button text appear despite the toolbar mode * gtk/gtkmenubar.c: add internal padding style property * gtk/gtktoolbar.c: Add internal padding style property; add shadow type style property * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget state; and put Container::border_width outside the frame * gtk/gtktextview.c: don't draw focus rectangle if we're in interior focus mode, we just use blinking cursor --- ChangeLog | 50 ++++ ChangeLog.pre-2-0 | 50 ++++ ChangeLog.pre-2-10 | 50 ++++ ChangeLog.pre-2-2 | 50 ++++ ChangeLog.pre-2-4 | 50 ++++ ChangeLog.pre-2-6 | 50 ++++ ChangeLog.pre-2-8 | 50 ++++ demos/gtk-demo/Makefile.am | 1 + demos/gtk-demo/appwindow.c | 342 ++++++++++++++++++++++ demos/gtk-demo/gtk-logo-rgb.gif | Bin 6459 -> 6427 bytes docs/Changes-2.0.txt | 25 +- docs/reference/gtk/tmpl/gtk-unused.sgml | 18 ++ docs/reference/gtk/tmpl/gtktoolbar.sgml | 3 +- docs/reference/gtk/tmpl/gtktypeutils.sgml | 20 -- gdk-pixbuf/ChangeLog | 6 + gdk-pixbuf/gdk-pixbuf-util.c | 56 ++-- gdk/x11/gdkevents-x11.c | 3 + gtk/gtkcolorsel.c | 30 +- gtk/gtkiconfactory.c | 2 +- gtk/gtkmenubar.c | 35 ++- gtk/gtksettings.c | 66 ++++- gtk/gtkstatusbar.c | 115 ++++++-- gtk/gtkstyle.c | 273 +++++++++++------ gtk/gtktextview.c | 75 +++-- gtk/gtktoolbar.c | 255 ++++++++++++++-- gtk/gtktoolbar.h | 15 +- tests/testgtk.c | 4 +- 27 files changed, 1480 insertions(+), 214 deletions(-) create mode 100644 demos/gtk-demo/appwindow.c diff --git a/ChangeLog b/ChangeLog index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index c4a2c973df..2cb0df82d2 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,53 @@ +2001-05-10 Havoc Pennington + + * gtk/gtksettings.c (gtk_settings_get_property): Handle case where + we need to parse the xsetting as if it were an RC file string. + + * gtk/gtkcolorsel.c (gtk_color_selection_class_init): load initial + value of palette from settings, not from static variable + + * gdk/x11/gdkevents-x11.c: add color palette, toolbar mode to + xsettings translation table + + * gtk/gtktoolbar.c (gtk_toolbar_new): Remove arguments, because + hardcoding the toolbar style conflicts with new customizable + toolbar style philosophy + (gtk_toolbar_class_init): add settings for default toolbar style; + these are used unless the app specifically forces a toolbar style + + * gtk/gtksettings.c (settings_install_property_parser): only + return at the start if we warn and parser == NULL + + * gtk/gtkcolorsel.c (gtk_color_selection_finalize): disconnect the + palette changed handler so we don't notify dead color selections + + * gtk/gtkstyle.c (gtk_default_draw_shadow): handle + xthickness/ythickness of 0 or 1 properly + (gtk_default_draw_resize_grip): clear the background behind the + resize grips, and align to bottom right if we square the + area to be drawn. + + * gtk/gtkstatusbar.c (gtk_statusbar_init): set horizontal usize on + statusbar label to 1, so it doesn't make toplevels resize oddly + (gtk_statusbar_size_request): add grip size to request + (gtk_statusbar_size_allocate): hack so the hbox still works with + the grip size in the request + + * gtk/gtktoolbar.c (gtk_toolbar_show_all): override to fix + bug where showing all on a toplevel makes the toolbar + button text appear despite the toolbar mode + + * gtk/gtkmenubar.c: add internal padding style property + + * gtk/gtktoolbar.c: Add internal padding style property; add + shadow type style property + + * gtk/gtkmenubar.c (gtk_menu_bar_paint): paint box with widget + state; and put Container::border_width outside the frame + + * gtk/gtktextview.c: don't draw focus rectangle if we're in + interior focus mode, we just use blinking cursor + 2001-06-04 Havoc Pennington * configure.in: Make gdk-pixbuf have same version number as GTK diff --git a/demos/gtk-demo/Makefile.am b/demos/gtk-demo/Makefile.am index a25c647dd6..0cfcbd76fa 100644 --- a/demos/gtk-demo/Makefile.am +++ b/demos/gtk-demo/Makefile.am @@ -5,6 +5,7 @@ democodedir=$(datadir)/gtk-2.0/demo ## These should be in the order you want them to appear in the ## demo app, which means alphabetized by demo title, not filename demos = @STRIP_BEGIN@ \ + appwindow.c \ button_box.c \ colorsel.c \ dialog.c \ diff --git a/demos/gtk-demo/appwindow.c b/demos/gtk-demo/appwindow.c new file mode 100644 index 0000000000..75c898ab86 --- /dev/null +++ b/demos/gtk-demo/appwindow.c @@ -0,0 +1,342 @@ +/* Application main window + * + * Demonstrates a typical application window, with menubar, toolbar, statusbar. + */ + +#include + +static GtkWidget *window = NULL; + + +static void +menuitem_cb (gpointer callback_data, + guint callback_action, + GtkWidget *widget) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (GTK_WINDOW (callback_data), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "You selected or toggled the menu item: \"%s\"", + gtk_item_factory_path_from_widget (widget)); + + /* Close dialog on user response */ + g_signal_connectc (G_OBJECT (dialog), + "response", + G_CALLBACK (gtk_widget_destroy), + NULL, + FALSE); + + gtk_widget_show (dialog); +} + + +static GtkItemFactoryEntry menu_items[] = +{ + { "/_File", NULL, 0, 0, "" }, + { "/File/tearoff1", NULL, menuitem_cb, 0, "" }, + { "/File/_New", "N", menuitem_cb, 0, "", GTK_STOCK_NEW }, + { "/File/_Open", "O", menuitem_cb, 0, "", GTK_STOCK_OPEN }, + { "/File/_Save", "S", menuitem_cb, 0, "", GTK_STOCK_SAVE }, + { "/File/Save _As...", NULL, menuitem_cb, 0, "", GTK_STOCK_SAVE }, + { "/File/sep1", NULL, menuitem_cb, 0, "" }, + { "/File/_Quit", "Q", menuitem_cb, 0, "", GTK_STOCK_QUIT }, + + { "/_Preferences", NULL, 0, 0, "" }, + { "/_Preferences/_Color", NULL, 0, 0, "" }, + { "/_Preferences/Color/_Red", NULL, menuitem_cb, 0, "" }, + { "/_Preferences/Color/_Green", NULL, menuitem_cb, 0, "/Preferences/Color/Red" }, + { "/_Preferences/Color/_Blue", NULL, menuitem_cb, 0, "/Preferences/Color/Red" }, + { "/_Preferences/_Shape", NULL, 0, 0, "" }, + { "/_Preferences/Shape/_Square", NULL, menuitem_cb, 0, "" }, + { "/_Preferences/Shape/_Rectangle", NULL, menuitem_cb, 0, "/Preferences/Shape/Square" }, + { "/_Preferences/Shape/_Oval", NULL, menuitem_cb, 0, "/Preferences/Shape/Rectangle" }, + + { "/_Help", NULL, 0, 0, "" }, + { "/Help/_About", NULL, menuitem_cb, 0 }, +}; + +static void +toolbar_cb (GtkWidget *button, + gpointer data) +{ + GtkWidget *dialog; + + dialog = gtk_message_dialog_new (GTK_WINDOW (data), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_INFO, + GTK_BUTTONS_CLOSE, + "You selected a toolbar button"); + + /* Close dialog on user response */ + g_signal_connectc (G_OBJECT (dialog), + "response", + G_CALLBACK (gtk_widget_destroy), + NULL, + FALSE); + + gtk_widget_show (dialog); +} + +/* This function registers our custom toolbar icons, so they can be themed. + * + * It's totally optional to do this, you could just manually insert icons + * and have them not be themeable, especially if you never expect people + * to theme your app. + */ +static void +register_stock_icons (void) +{ + static gboolean registered = FALSE; + + if (!registered) + { + GdkPixbuf *pixbuf; + GtkIconFactory *factory; + + static GtkStockItem items[] = { + { "demo-gtk-logo", + "_GTK!", + 0, 0, NULL } + }; + + registered = TRUE; + + /* Register our stock items */ + gtk_stock_add (items, G_N_ELEMENTS (items)); + + /* Add our custom icon factory to the list of defaults */ + factory = gtk_icon_factory_new (); + gtk_icon_factory_add_default (factory); + + /* Try current directory */ + pixbuf = gdk_pixbuf_new_from_file ("./gtk-logo-rgb.gif", NULL); + + /* Try install directory */ + if (pixbuf == NULL) + pixbuf = gdk_pixbuf_new_from_file (DEMOCODEDIR"/gtk-logo-rgb.gif", NULL); + + /* Register icon to accompany stock item */ + if (pixbuf != NULL) + { + GtkIconSet *icon_set; + GdkPixbuf *transparent; + + /* The gtk-logo-rgb icon has a white background, make it transparent */ + transparent = gdk_pixbuf_add_alpha (pixbuf, TRUE, 0xff, 0xff, 0xff); + + icon_set = gtk_icon_set_new_from_pixbuf (transparent); + gtk_icon_factory_add (factory, "demo-gtk-logo", icon_set); + gtk_icon_set_unref (icon_set); + g_object_unref (G_OBJECT (pixbuf)); + g_object_unref (G_OBJECT (transparent)); + } + else + g_warning ("failed to load GTK logo for toolbar"); + + /* Drop our reference to the factory, GTK will hold a reference. */ + g_object_unref (G_OBJECT (factory)); + } +} + +static void +update_statusbar (GtkTextBuffer *buffer, + GtkStatusbar *statusbar) +{ + gchar *msg; + gint row, col; + gint count; + GtkTextIter iter; + + gtk_statusbar_pop (statusbar, 0); /* clear any previous message, underflow is allowed */ + + count = gtk_text_buffer_get_char_count (buffer); + + gtk_text_buffer_get_iter_at_mark (buffer, + &iter, + gtk_text_buffer_get_insert (buffer)); + + row = gtk_text_iter_get_line (&iter); + col = gtk_text_iter_get_line_offset (&iter); + + msg = g_strdup_printf ("Cursor at row %d column %d - %d chars in document", + row, col, count); + + gtk_statusbar_push (statusbar, 0, msg); + + g_free (msg); +} + +static void +mark_set_callback (GtkTextBuffer *buffer, + const GtkTextIter *new_location, + GtkTextMark *mark, + gpointer data) +{ + update_statusbar (buffer, GTK_STATUSBAR (data)); +} + +GtkWidget * +do_appwindow (void) +{ + if (!window) + { + GtkWidget *table; + GtkWidget *toolbar; + GtkWidget *statusbar; + GtkWidget *contents; + GtkWidget *sw; + GtkTextBuffer *buffer; + GtkAccelGroup *accel_group; + GtkItemFactory *item_factory; + + register_stock_icons (); + + /* Create the toplevel window + */ + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (window), "Application Window"); + + /* NULL window variable when window is closed */ + g_signal_connectc (G_OBJECT (window), "destroy", + G_CALLBACK (gtk_widget_destroyed), + &window, TRUE); + + table = gtk_table_new (1, 4, FALSE); + + gtk_container_add (GTK_CONTAINER (window), table); + + /* Create the menubar + */ + + accel_group = gtk_accel_group_new (); + gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); + gtk_accel_group_unref (accel_group); + + item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "
", accel_group); + + /* Set up item factory to go away with the window */ + gtk_object_ref (GTK_OBJECT (item_factory)); + gtk_object_sink (GTK_OBJECT (item_factory)); + g_object_set_data_full (G_OBJECT (window), + "
", + item_factory, + (GDestroyNotify) g_object_unref); + + /* create menu items */ + gtk_item_factory_create_items (item_factory, G_N_ELEMENTS (menu_items), + menu_items, window); + + gtk_table_attach (GTK_TABLE (table), + gtk_item_factory_get_widget (item_factory, "
"), + /* X direction */ /* Y direction */ + 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + + /* Create the toolbar + */ + toolbar = gtk_toolbar_new (); + + gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar), + GTK_STOCK_OPEN, + "This is a demo button with an 'open' icon", + NULL, + G_CALLBACK (toolbar_cb), + window, /* user data for callback */ + -1); /* -1 means "append" */ + + gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar), + GTK_STOCK_QUIT, + "This is a demo button with a 'quit' icon", + NULL, + G_CALLBACK (toolbar_cb), + window, /* user data for callback */ + -1); /* -1 means "append" */ + + gtk_toolbar_append_space (GTK_TOOLBAR (toolbar)); + + gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar), + "demo-gtk-logo", + "This is a demo button with a 'gtk' icon", + NULL, + G_CALLBACK (toolbar_cb), + window, /* user data for callback */ + -1); /* -1 means "append" */ + + gtk_table_attach (GTK_TABLE (table), + toolbar, + /* X direction */ /* Y direction */ + 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + + /* Create document + */ + + sw = gtk_scrolled_window_new (NULL, NULL); + + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), + GTK_SHADOW_IN); + + gtk_table_attach (GTK_TABLE (table), + sw, + /* X direction */ /* Y direction */ + 0, 1, 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, + 0, 0); + + gtk_window_set_default_size (GTK_WINDOW (window), + 200, 200); + + contents = gtk_text_view_new (); + + gtk_container_add (GTK_CONTAINER (sw), + contents); + + /* Create statusbar */ + + statusbar = gtk_statusbar_new (); + gtk_table_attach (GTK_TABLE (table), + statusbar, + /* X direction */ /* Y direction */ + 0, 1, 3, 4, + GTK_EXPAND | GTK_FILL, 0, + 0, 0); + + /* Show text widget info in the statusbar */ + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (contents)); + + g_signal_connectc (G_OBJECT (buffer), + "changed", + G_CALLBACK (update_statusbar), + statusbar, FALSE); + + g_signal_connectc (G_OBJECT (buffer), + "mark_set", /* cursor moved */ + G_CALLBACK (mark_set_callback), + statusbar, FALSE); + + update_statusbar (buffer, GTK_STATUSBAR (statusbar)); + } + + if (!GTK_WIDGET_VISIBLE (window)) + { + gtk_widget_show_all (window); + } + else + { + gtk_widget_destroy (window); + window = NULL; + } + + return window; +} + diff --git a/demos/gtk-demo/gtk-logo-rgb.gif b/demos/gtk-demo/gtk-logo-rgb.gif index f6e934d5e6f4ccf1aeec787aa70da7232ec21e70..63c622b93c1e5d9a7bed9ed304ccf05d4da80609 100644 GIT binary patch literal 6427 zcmX|k`9GA4x4NZZI4Rubck?rb~m)Dp;<&B@mK@` z4aFrH8`^rAg}80o=3udfYUn`H@x^P~nK1KpHbXDoDlC27sXDr5Oh*ENL?CWLspBvx zJ)>>an^Wg)V@7$RLx$?UmfL!_q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3_B0wRo-aJtv#P(4fu0%Ph?^QKl?}pIDImzds|rS(arPTUs-3N^ix(?}1r5LcXyJB`Q_S)%w&vp zh6!yi3h@yEj2Sq1PX!^wHW}KGs1Eg=E^eT(4&9?Q<)PKqFnhljG4`26R6M^o2uTa| zlVn4SU%+4PBiIGZaEr#jSiX4OHf|ed;BNNZ%m4V%j)iHdb@E_gD#hmc_d-Sy6owmL z|9x)dwB0m|xuqW>OUrXSMP={Ius+vl=J_bc-sUm5Xm1|LNL;}LqgS1---+&r8YKXe zEQ^Kyg^eW^Ut<^V)tC0rq5fk5515ZcwFJrWEzUy0Bor8spT*b#2bVQV%=T4v_}ZDu zww0FiuhjYtNenhpSFM z{3LfxkVE%7)&~Pke;llpzEF6Tp6b3~v!@{5Xr-Bfy5Kp>dLH z#)R7VKUQvX*V-Z@Bn}qWpnAhuhDHEk;`6~sz+7ddHGZ&_g}%i?t6AtGt^rZ<4MYw~ z7L_rFK+i5}!8Jm^4T3cKImtbczg08%AnZ*s+JciqJ^D?<6I?N;^20qilkyHri+JJD)qp+~zatVYd&td|m>A)h(atG@YW5JFX)B z>XPw*!`5AdElbOz1kI+wu-v-)BdbW}*DC0TILmc}GO*P7`8Pli_I+(f^}Rt`pVnM| zGNUAIN1CjCr#a-k7-lE?b1CG|yGYyM=6|eVc48th&bW`0!cYyM zMgWjR_femT^|VJ296CUa{1JaptJYwB5tJPKg5O~3a!Q6@!#(2kAdF0%c&!PP0mI(y zu=+5Ky(nEj2Xg45pv_2IyA?o6_WQyL6u`1*?of-1mUGWMfn(_IeYFUN!taN1(##?T zr>)Sall(^N583g%+9s$IY3L*2|2+JQGzwlESmN6Sk1U&~m3~inc(sP&u!8jSKm!S$ zr7~F=wZ{oR<6;6gh)QW`Bt;H?S%CDWOrP1nh~m#R$3Hxu_7x + + +Define a function pointer. Deprecated. + + +@object: +@arg: +@arg_id: + + + +Define a function pointer. Deprecated. + + +@object: +@arg: +@arg_id: + diff --git a/docs/reference/gtk/tmpl/gtktoolbar.sgml b/docs/reference/gtk/tmpl/gtktoolbar.sgml index e96aba29a1..97c9f6329d 100644 --- a/docs/reference/gtk/tmpl/gtktoolbar.sgml +++ b/docs/reference/gtk/tmpl/gtktoolbar.sgml @@ -78,9 +78,10 @@ SPACE is just a space in the style of the toolbar's GtkToolbarSpaceStyle. BUTTON creates a new toolbar. +@Returns: the newly created toolbar. + @orientation: a #GtkOrientation. It determines whether the toolbar appears horizontally or vertically. @style: a #GtkToolbarStyle. It determines if the toolbar will contain buttons with just labels, just images, or both. -@Returns: the newly created toolbar. diff --git a/docs/reference/gtk/tmpl/gtktypeutils.sgml b/docs/reference/gtk/tmpl/gtktypeutils.sgml index e6a3ad7abf..5b35e66bcf 100644 --- a/docs/reference/gtk/tmpl/gtktypeutils.sgml +++ b/docs/reference/gtk/tmpl/gtktypeutils.sgml @@ -217,26 +217,6 @@ Define a function pointer. - - -Define a function pointer. Deprecated. - - -@object: -@arg: -@arg_id: - - - - -Define a function pointer. Deprecated. - - -@object: -@arg: -@arg_id: - - A GtkTypeObject defines the minimum structure requirements diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index edeb03b1a5..06960c42da 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,9 @@ +2001-05-08 Havoc Pennington + + * gdk-pixbuf-util.c (gdk_pixbuf_add_alpha): docs fixup, + and fix behavior to still subst color if the original image + had alpha + 2001-06-04 Havoc Pennington * io-pnm.c (pnm_skip_whitespace): patch from Szekeres Istvan, diff --git a/gdk-pixbuf/gdk-pixbuf-util.c b/gdk-pixbuf/gdk-pixbuf-util.c index 0f869b9471..16c32bb2b7 100644 --- a/gdk-pixbuf/gdk-pixbuf-util.c +++ b/gdk-pixbuf/gdk-pixbuf-util.c @@ -30,18 +30,20 @@ /** * gdk_pixbuf_add_alpha: * @pixbuf: A pixbuf. - * @substitute_color: Whether to substitute a color for zero opacity. If this + * @substitute_color: Whether to set a color to zero opacity. If this * is #FALSE, then the (@r, @g, @b) arguments will be ignored. * @r: Red value to substitute. * @g: Green value to substitute. * @b: Blue value to substitute. * - * Takes an existing pixbuf and adds an alpha channel to it. If the original - * pixbuf already had alpha information, then the contents of the new pixbuf are - * exactly the same as the original's. Otherwise, the new pixbuf will have all - * pixels with full opacity if @substitute_color is #FALSE. If - * @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be - * substituted for zero opacity. + * Takes an existing pixbuf and adds an alpha channel to it. + * If the existing pixbuf already had an alpha channel, the channel + * values are copied from the original; otherwise, the alpha channel + * is initialized to 255 (full opacity). + * + * If @substitute_color is #TRUE, then the color specified by (@r, @g, @b) will be + * assigned zero opacity. That is, if you pass (255, 255, 255) for the + * substitute color, all white pixels will become fully transparent. * * Return value: A newly-created pixbuf with a reference count of 1. **/ @@ -62,10 +64,12 @@ gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, if (!new_pixbuf) return NULL; - return new_pixbuf; - } - - new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height); + if (!substitute_color) + return new_pixbuf; + } else { + new_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, pixbuf->width, pixbuf->height); + } + if (!new_pixbuf) return NULL; @@ -75,16 +79,26 @@ gdk_pixbuf_add_alpha (const GdkPixbuf *pixbuf, src = pixbuf->pixels + y * pixbuf->rowstride; dest = new_pixbuf->pixels + y * new_pixbuf->rowstride; - - for (x = 0; x < pixbuf->width; x++) { - tr = *dest++ = *src++; - tg = *dest++ = *src++; - tb = *dest++ = *src++; - - if (substitute_color && tr == r && tg == g && tb == b) - *dest++ = 0; - else - *dest++ = 255; + + if (pixbuf->has_alpha) { + /* Just subst color, we already copied everything else */ + for (x = 0; x < pixbuf->width; x++) { + if (src[0] == r && src[1] == g && src[2] == b) + dest[3] = 0; + src += 4; + dest += 4; + } + } else { + for (x = 0; x < pixbuf->width; x++) { + tr = *dest++ = *src++; + tg = *dest++ = *src++; + tb = *dest++ = *src++; + + if (substitute_color && tr == r && tg == g && tb == b) + *dest++ = 0; + else + *dest++ = 255; + } } } diff --git a/gdk/x11/gdkevents-x11.c b/gdk/x11/gdkevents-x11.c index ab931ad82e..305f7b6157 100644 --- a/gdk/x11/gdkevents-x11.c +++ b/gdk/x11/gdkevents-x11.c @@ -1913,6 +1913,9 @@ static struct } settings_map[] = { { "Net/DoubleClickTime", "gtk-double-click-timeout" }, { "Net/DragThreshold", "gtk-drag-threshold" }, + { "Gtk/ColorPalette", "gtk-color-palette" }, + { "Gtk/ToolbarStyle", "gtk-toolbar-style" }, + { "Gtk/ToolbarIconSize", "gtk-toolbar-icon-size" }, { "Net/CursorBlink", "gtk-cursor-blink" }, { "Net/CursorBlinkTime", "gtk-cursor-blink-time" } }; diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index f14e2654d9..02f847d7c3 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -126,6 +126,9 @@ struct _ColorSelectionPrivate /* Window for grabbing on */ GtkWidget *dropper_grab_widget; + + /* Connection to settings */ + guint settings_connection; }; @@ -1621,6 +1624,7 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass) { GtkObjectClass *object_class; GObjectClass *gobject_class; + gchar *palette; object_class = GTK_OBJECT_CLASS (klass); gobject_class = G_OBJECT_CLASS (klass); @@ -1644,8 +1648,14 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass) _("Palette to use in the color selector"), default_colors, G_PARAM_READWRITE)); + + g_object_get (G_OBJECT (gtk_settings_get_global ()), + "gtk-color-palette", + &palette, + NULL); - fill_palette_from_string (default_colors); + fill_palette_from_string (palette); + g_free (palette); change_palette_hook = default_change_palette_func; @@ -1813,11 +1823,12 @@ gtk_color_selection_init (GtkColorSelection *colorsel) /* Set default colors */ update_palette (colorsel); - - g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()), - "notify::gtk-color-palette", - G_CALLBACK (palette_change_notify_instance), - colorsel, NULL, FALSE, FALSE); + + priv->settings_connection = + g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()), + "notify::gtk-color-palette", + G_CALLBACK (palette_change_notify_instance), + colorsel, NULL, FALSE, FALSE); /* hide unused stuff */ @@ -1862,6 +1873,13 @@ gtk_color_selection_finalize (GObject *object) if (cselection->private_data) { + ColorSelectionPrivate *priv; + + priv = cselection->private_data; + + g_signal_handler_disconnect (gtk_settings_get_global (), + priv->settings_connection); + g_free (cselection->private_data); cselection->private_data = NULL; } diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index f4d025a041..697281f753 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -313,7 +313,7 @@ gtk_icon_factory_lookup_default (const gchar *stock_id) if (icon_set) return icon_set; - + tmp_list = g_slist_next (tmp_list); } diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c index 9616638422..9965fef932 100644 --- a/gtk/gtkmenubar.c +++ b/gtk/gtkmenubar.c @@ -37,7 +37,7 @@ #define BORDER_SPACING 0 #define CHILD_SPACING 3 - +#define DEFAULT_IPADDING 1 static void gtk_menu_bar_class_init (GtkMenuBarClass *klass); static void gtk_menu_bar_size_request (GtkWidget *widget, @@ -136,6 +136,16 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class) GTK_TYPE_SHADOW_TYPE, GTK_SHADOW_OUT, G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("internal_padding", + _("Internal padding"), + _("Amount of border space between the menubar shadow and the menu items"), + 0, + G_MAXINT, + DEFAULT_IPADDING, + G_PARAM_READABLE)); + } GtkWidget* @@ -177,6 +187,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, GList *children; gint nchildren; GtkRequisition child_requisition; + gint ipadding; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_BAR (widget)); @@ -184,7 +195,7 @@ gtk_menu_bar_size_request (GtkWidget *widget, requisition->width = 0; requisition->height = 0; - + if (GTK_WIDGET_VISIBLE (widget)) { menu_bar = GTK_MENU_BAR (widget); @@ -222,11 +233,15 @@ gtk_menu_bar_size_request (GtkWidget *widget, } } + gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL); + requisition->width += (GTK_CONTAINER (menu_bar)->border_width + widget->style->xthickness + + ipadding + BORDER_SPACING) * 2; requisition->height += (GTK_CONTAINER (menu_bar)->border_width + widget->style->ythickness + + ipadding + BORDER_SPACING) * 2; if (nchildren > 0) @@ -245,6 +260,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, GtkAllocation child_allocation; GtkRequisition child_requisition; guint offset; + gint ipadding; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_MENU_BAR (widget)); @@ -259,15 +275,19 @@ gtk_menu_bar_size_allocate (GtkWidget *widget, allocation->x, allocation->y, allocation->width, allocation->height); + gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL); + if (menu_shell->children) { child_allocation.x = (GTK_CONTAINER (menu_bar)->border_width + widget->style->xthickness + + ipadding + BORDER_SPACING); offset = child_allocation.x; /* Window edge to menubar start */ child_allocation.y = (GTK_CONTAINER (menu_bar)->border_width + widget->style->ythickness + + ipadding + BORDER_SPACING); child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2); @@ -314,13 +334,18 @@ gtk_menu_bar_paint (GtkWidget *widget, GdkRectangle *area) if (GTK_WIDGET_DRAWABLE (widget)) { + gint border; + + border = GTK_CONTAINER (widget)->border_width; + gtk_paint_box (widget->style, widget->window, - GTK_STATE_NORMAL, + GTK_WIDGET_STATE (widget), get_shadow_type (GTK_MENU_BAR (widget)), area, widget, "menubar", - 0, 0, - -1,-1); + border, border, + widget->allocation.width - border * 2, + widget->allocation.height - border * 2); } } diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index ee5c187dbe..3fe8f49277 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -219,10 +219,58 @@ gtk_settings_get_property (GObject *object, { GtkSettings *settings = GTK_SETTINGS (object); - if (gdk_setting_get (pspec->name, value)) - g_param_value_validate (pspec, value); + if (g_value_type_transformable (G_TYPE_INT, G_VALUE_TYPE (value)) || + g_value_type_transformable (G_TYPE_STRING, G_VALUE_TYPE (value)) || + g_value_type_transformable (GDK_TYPE_COLOR, G_VALUE_TYPE (value))) + { + if (gdk_setting_get (pspec->name, value)) + g_param_value_validate (pspec, value); + else + g_value_copy (settings->property_values + property_id - 1, value); + } else - g_value_copy (settings->property_values + property_id - 1, value); + { + GValue val = { 0, }; + + /* Try to get xsetting as a string and parse it. */ + + g_value_init (&val, G_TYPE_STRING); + + if (!gdk_setting_get (pspec->name, &val)) + { + g_value_copy (settings->property_values + property_id - 1, value); + } + else + { + GValue tmp_value = { 0, }; + GValue gstring_value = { 0, }; + GtkRcPropertyParser parser = g_param_spec_get_qdata (pspec, + quark_property_parser); + + g_value_init (&gstring_value, G_TYPE_GSTRING); + + g_value_set_boxed (&gstring_value, + g_string_new (g_value_get_string (&val))); + + g_value_init (&tmp_value, G_PARAM_SPEC_VALUE_TYPE (pspec)); + + if (parser && _gtk_settings_parse_convert (parser, &gstring_value, + pspec, &tmp_value)) + { + g_value_copy (&tmp_value, value); + g_param_value_validate (pspec, value); + } + else + { + g_value_copy (settings->property_values + property_id - 1, value); + } + + g_value_unset (&gstring_value); + g_value_unset (&tmp_value); + } + + g_value_unset (&val); + } } static void @@ -359,9 +407,11 @@ settings_install_property_parser (GtkSettingsClass *class, break; default: if (!parser) - g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'", - pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); - return 0; + { + g_warning (G_STRLOC ": parser needs to be specified for property \"%s\" of type `%s'", + pspec->name, g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec))); + return 0; + } } if (g_object_class_find_property (G_OBJECT_CLASS (class), pspec->name)) { @@ -617,7 +667,7 @@ gtk_rc_property_parse_enum (const GParamSpec *pspec, if (scanner->token == G_TOKEN_IDENTIFIER) { GEnumClass *class = G_PARAM_SPEC_ENUM (pspec)->enum_class; - + enum_value = g_enum_get_value_by_name (class, scanner->value.v_identifier); if (!enum_value) enum_value = g_enum_get_value_by_nick (class, scanner->value.v_identifier); @@ -820,7 +870,7 @@ void _gtk_settings_handle_event (GdkEventSetting *event) { GtkSettings *settings = gtk_settings_get_global (); - + if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings), event->name)) g_object_notify (G_OBJECT (settings), event->name); } diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c index 1ca1466ffa..a032eb7fad 100644 --- a/gtk/gtkstatusbar.c +++ b/gtk/gtkstatusbar.c @@ -30,6 +30,7 @@ #include "gtksignal.h" #include "gtkstatusbar.h" #include "gtkwindow.h" +#include "gtkintl.h" typedef struct _GtkStatusbarMsg GtkStatusbarMsg; @@ -63,6 +64,10 @@ static gboolean gtk_statusbar_button_press (GtkWidget *widget, GdkEventButton *event); static gboolean gtk_statusbar_expose_event (GtkWidget *widget, GdkEventExpose *event); +static void gtk_statusbar_size_request (GtkWidget *widget, + GtkRequisition *requisition); +static void gtk_statusbar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); static void gtk_statusbar_create_window (GtkStatusbar *statusbar); static void gtk_statusbar_destroy_window (GtkStatusbar *statusbar); @@ -109,8 +114,6 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) object_class->destroy = gtk_statusbar_destroy; - widget_class->size_allocate = gtk_statusbar_size_allocate; - widget_class->realize = gtk_statusbar_realize; widget_class->unrealize = gtk_statusbar_unrealize; widget_class->map = gtk_statusbar_map; @@ -118,6 +121,9 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) widget_class->button_press_event = gtk_statusbar_button_press; widget_class->expose_event = gtk_statusbar_expose_event; + + widget_class->size_request = gtk_statusbar_size_request; + widget_class->size_allocate = gtk_statusbar_size_allocate; class->messages_mem_chunk = g_mem_chunk_new ("GtkStatusBar messages mem chunk", sizeof (GtkStatusbarMsg), @@ -145,27 +151,42 @@ gtk_statusbar_class_init (GtkStatusbarClass *class) GTK_TYPE_NONE, 2, GTK_TYPE_UINT, GTK_TYPE_STRING); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_enum ("shadow_type", + _("Shadow type"), + _("Style of bevel around the statusbar text"), + GTK_TYPE_SHADOW_TYPE, + GTK_SHADOW_IN, + G_PARAM_READABLE)); } static void gtk_statusbar_init (GtkStatusbar *statusbar) { GtkBox *box; - + GtkShadowType shadow_type; + box = GTK_BOX (statusbar); box->spacing = 2; box->homogeneous = FALSE; statusbar->has_resize_grip = TRUE; + + gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL); statusbar->frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), GTK_SHADOW_IN); + gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type); gtk_box_pack_start (box, statusbar->frame, TRUE, TRUE, 0); gtk_widget_show (statusbar->frame); statusbar->label = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.0); + /* don't expand the size request for the label; if we + * do that then toplevels weirdly resize + */ + gtk_widget_set_usize (statusbar->label, 1, -1); gtk_container_add (GTK_CONTAINER (statusbar->frame), statusbar->label); gtk_widget_show (statusbar->label); @@ -425,25 +446,6 @@ get_grip_rect (GtkStatusbar *statusbar, rect->height = h; } -static void -gtk_statusbar_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkStatusbar *statusbar; - GdkRectangle rect; - - statusbar = GTK_STATUSBAR (widget); - - GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); - - get_grip_rect (statusbar, &rect); - - if (statusbar->grip_window) - gdk_window_move_resize (statusbar->grip_window, - rect.x, rect.y, - rect.width, rect.height); -} - static void gtk_statusbar_create_window (GtkStatusbar *statusbar) { @@ -583,7 +585,7 @@ gtk_statusbar_expose_event (GtkWidget *widget, if (statusbar->has_resize_grip) { get_grip_rect (statusbar, &rect); - + gtk_paint_resize_grip (widget->style, widget->window, GTK_WIDGET_STATE (widget), @@ -601,3 +603,68 @@ gtk_statusbar_expose_event (GtkWidget *widget, return FALSE; } + +static void +gtk_statusbar_size_request (GtkWidget *widget, + GtkRequisition *requisition) +{ + GtkStatusbar *statusbar; + GtkShadowType shadow_type; + + statusbar = GTK_STATUSBAR (widget); + + gtk_widget_style_get (GTK_WIDGET (statusbar), "shadow_type", &shadow_type, NULL); + gtk_frame_set_shadow_type (GTK_FRAME (statusbar->frame), shadow_type); + + GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + + if (statusbar->has_resize_grip) + { + GdkRectangle rect; + + /* x, y in the grip rect depend on size allocation, but + * w, h do not so this is OK + */ + get_grip_rect (statusbar, &rect); + + requisition->width += rect.width; + requisition->height = MAX (requisition->height, rect.height); + } +} + +static void +gtk_statusbar_size_allocate (GtkWidget *widget, + GtkAllocation *allocation) +{ + GtkStatusbar *statusbar; + + statusbar = GTK_STATUSBAR (widget); + + if (statusbar->has_resize_grip) + { + GdkRectangle rect; + GtkAllocation hbox_allocation; + GtkRequisition saved_req; + + widget->allocation = *allocation; /* get_grip_rect needs this info */ + get_grip_rect (statusbar, &rect); + + if (statusbar->grip_window) + gdk_window_move_resize (statusbar->grip_window, + rect.x, rect.y, + rect.width, rect.height); + + /* enter the bad hack zone */ + saved_req = widget->requisition; + widget->requisition.width -= rect.width; /* HBox::size_allocate needs this */ + if (widget->requisition.width < 0) + widget->requisition.width = 0; + GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + widget->requisition = saved_req; + } + else + { + /* chain up normally */ + GTK_WIDGET_CLASS (parent_class)->size_allocate (widget, allocation); + } +} diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c index 6aaf330549..e0c526ecd9 100644 --- a/gtk/gtkstyle.c +++ b/gtk/gtkstyle.c @@ -2116,103 +2116,188 @@ gtk_default_draw_shadow (GtkStyle *style, break; case GTK_SHADOW_IN: - gdk_draw_line (window, gc1, - x, y + height - 1, x + width - 1, y + height - 1); - gdk_draw_line (window, gc1, - x + width - 1, y, x + width - 1, y + height - 1); - - gdk_draw_line (window, style->bg_gc[state_type], - x + 1, y + height - 2, x + width - 2, y + height - 2); - gdk_draw_line (window, style->bg_gc[state_type], - x + width - 2, y + 1, x + width - 2, y + height - 2); - - gdk_draw_line (window, style->black_gc, - x + 1, y + 1, x + width - 2, y + 1); - gdk_draw_line (window, style->black_gc, - x + 1, y + 1, x + 1, y + height - 2); - - gdk_draw_line (window, gc2, - x, y, x + width - 1, y); - gdk_draw_line (window, gc2, - x, y, x, y + height - 1); + /* Light around right and bottom edge */ + + if (style->ythickness > 0) + gdk_draw_line (window, gc1, + x, y + height - 1, x + width - 1, y + height - 1); + if (style->xthickness > 0) + gdk_draw_line (window, gc1, + x + width - 1, y, x + width - 1, y + height - 1); + + if (style->ythickness > 1) + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + height - 2, x + width - 2, y + height - 2); + if (style->xthickness > 1) + gdk_draw_line (window, style->bg_gc[state_type], + x + width - 2, y + 1, x + width - 2, y + height - 2); + + /* Dark around left and top */ + + if (style->ythickness > 1) + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + width - 2, y + 1); + if (style->xthickness > 1) + gdk_draw_line (window, style->black_gc, + x + 1, y + 1, x + 1, y + height - 2); + + if (style->ythickness > 0) + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + if (style->xthickness > 0) + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); break; case GTK_SHADOW_OUT: - gdk_draw_line (window, gc1, - x + 1, y + height - 2, x + width - 2, y + height - 2); - gdk_draw_line (window, gc1, - x + width - 2, y + 1, x + width - 2, y + height - 2); - - gdk_draw_line (window, gc2, - x, y, x + width - 1, y); - gdk_draw_line (window, gc2, - x, y, x, y + height - 1); - - gdk_draw_line (window, style->bg_gc[state_type], - x + 1, y + 1, x + width - 2, y + 1); - gdk_draw_line (window, style->bg_gc[state_type], - x + 1, y + 1, x + 1, y + height - 2); + /* Dark around right and bottom edge */ + + if (style->ythickness > 0) + { + if (style->ythickness > 1) + { + gdk_draw_line (window, gc1, + x + 1, y + height - 2, x + width - 2, y + height - 2); + gdk_draw_line (window, style->black_gc, + x, y + height - 1, x + width - 1, y + height - 1); + } + else + { + gdk_draw_line (window, gc1, + x + 1, y + height - 1, x + width - 1, y + height - 1); + } + } + + if (style->xthickness > 0) + { + if (style->xthickness > 1) + { + gdk_draw_line (window, gc1, + x + width - 2, y + 1, x + width - 2, y + height - 2); + + gdk_draw_line (window, style->black_gc, + x + width - 1, y, x + width - 1, y + height - 1); + } + else + { + gdk_draw_line (window, gc1, + x + width - 1, y + 1, x + width - 1, y + height - 1); + } + } - gdk_draw_line (window, style->black_gc, - x, y + height - 1, x + width - 1, y + height - 1); - gdk_draw_line (window, style->black_gc, - x + width - 1, y, x + width - 1, y + height - 1); + /* Light around top and left */ + + if (style->ythickness > 0) + gdk_draw_line (window, gc2, + x, y, x + width - 1, y); + if (style->xthickness > 0) + gdk_draw_line (window, gc2, + x, y, x, y + height - 1); + + if (style->ythickness > 1) + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + width - 2, y + 1); + if (style->xthickness > 1) + gdk_draw_line (window, style->bg_gc[state_type], + x + 1, y + 1, x + 1, y + height - 2); break; case GTK_SHADOW_ETCHED_IN: case GTK_SHADOW_ETCHED_OUT: - thickness_light = 1; - thickness_dark = 1; + if (style->xthickness > 0) + { + if (style->xthickness > 1) + { + thickness_light = 1; + thickness_dark = 1; - for (i = 0; i < thickness_dark; i++) + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, gc1, + x + width - i - 1, + y + i, + x + width - i - 1, + y + height - i - 1); + gdk_draw_line (window, gc2, + x + i, + y + i, + x + i, + y + height - i - 2); + } + + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + thickness_dark + i, + y + height - thickness_dark - i - 1); + gdk_draw_line (window, gc2, + x + width - thickness_light - i - 1, + y + thickness_dark + i, + x + width - thickness_light - i - 1, + y + height - thickness_light - 1); + } + } + else + { + gdk_draw_line (window, + style->dark_gc[state_type], + x, y, x, y + height); + gdk_draw_line (window, + style->dark_gc[state_type], + x + width, y, x + width, y + height); + } + } + + if (style->ythickness > 0) { - gdk_draw_line (window, gc1, - x + i, - y + height - i - 1, - x + width - i - 1, - y + height - i - 1); - gdk_draw_line (window, gc1, - x + width - i - 1, - y + i, - x + width - i - 1, - y + height - i - 1); + if (style->ythickness > 1) + { + thickness_light = 1; + thickness_dark = 1; + + for (i = 0; i < thickness_dark; i++) + { + gdk_draw_line (window, gc1, + x + i, + y + height - i - 1, + x + width - i - 1, + y + height - i - 1); - gdk_draw_line (window, gc2, - x + i, - y + i, - x + width - i - 2, - y + i); - gdk_draw_line (window, gc2, - x + i, - y + i, - x + i, - y + height - i - 2); - } + gdk_draw_line (window, gc2, + x + i, + y + i, + x + width - i - 2, + y + i); + } - for (i = 0; i < thickness_light; i++) - { - gdk_draw_line (window, gc1, - x + thickness_dark + i, - y + thickness_dark + i, - x + width - thickness_dark - i - 1, - y + thickness_dark + i); - gdk_draw_line (window, gc1, - x + thickness_dark + i, - y + thickness_dark + i, - x + thickness_dark + i, - y + height - thickness_dark - i - 1); + for (i = 0; i < thickness_light; i++) + { + gdk_draw_line (window, gc1, + x + thickness_dark + i, + y + thickness_dark + i, + x + width - thickness_dark - i - 1, + y + thickness_dark + i); - gdk_draw_line (window, gc2, - x + thickness_dark + i, - y + height - thickness_light - i - 1, - x + width - thickness_light - 1, - y + height - thickness_light - i - 1); - gdk_draw_line (window, gc2, - x + width - thickness_light - i - 1, - y + thickness_dark + i, - x + width - thickness_light - i - 1, - y + height - thickness_light - 1); + gdk_draw_line (window, gc2, + x + thickness_dark + i, + y + height - thickness_light - i - 1, + x + width - thickness_light - 1, + y + height - thickness_light - i - 1); + } + } + else + { + gdk_draw_line (window, + style->dark_gc[state_type], + x, y, x + width, y); + gdk_draw_line (window, + style->dark_gc[state_type], + x, y + height, x + width, y + height); + } } + break; } if (area) @@ -4157,11 +4242,26 @@ gtk_default_draw_resize_grip (GtkStyle *style, { gdk_gc_set_clip_rectangle (style->light_gc[state_type], area); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], area); } - /* make it square */ - if (width != height) - width = height = MIN (width, height); + /* make it square, aligning to bottom right */ + if (width < height) + { + y += (height - width); + height = width; + } + else if (height < width) + { + x += (width - height); + width = height; + } + + /* Clear background */ + gdk_draw_rectangle (window, + style->bg_gc[state_type], + TRUE, + x, y, width, height); switch (edge) { @@ -4209,6 +4309,7 @@ gtk_default_draw_resize_grip (GtkStyle *style, { gdk_gc_set_clip_rectangle (style->light_gc[state_type], NULL); gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL); + gdk_gc_set_clip_rectangle (style->bg_gc[state_type], NULL); } } diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index 95b3b4b00a..c8299e9ea3 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -76,8 +76,6 @@ * */ -#define FOCUS_EDGE_WIDTH 1 - #define SCREEN_WIDTH(widget) text_window_get_width (GTK_TEXT_VIEW (widget)->text_window) #define SCREEN_HEIGHT(widget) text_window_get_height (GTK_TEXT_VIEW (widget)->text_window) @@ -2236,7 +2234,7 @@ gtk_text_view_get_property (GObject *object, case PROP_EDITABLE: g_value_set_boolean (value, text_view->editable); break; - + case PROP_WRAP_MODE: g_value_set_enum (value, text_view->wrap_mode); break; @@ -2277,14 +2275,23 @@ gtk_text_view_size_request (GtkWidget *widget, { GtkTextView *text_view; GSList *tmp_list; - + gint focus_edge_width; + gboolean interior_focus; + text_view = GTK_TEXT_VIEW (widget); + gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL); + + if (interior_focus) + focus_edge_width = 0; + else + focus_edge_width = 1; + text_view->text_window->requisition.width = text_view->layout->width; text_view->text_window->requisition.height = text_view->layout->height; - requisition->width = text_view->text_window->requisition.width + FOCUS_EDGE_WIDTH * 2; - requisition->height = text_view->text_window->requisition.height + FOCUS_EDGE_WIDTH * 2; + requisition->width = text_view->text_window->requisition.width + focus_edge_width * 2; + requisition->height = text_view->text_window->requisition.height + focus_edge_width * 2; if (text_view->left_window) requisition->width += text_view->left_window->requisition.width; @@ -2430,7 +2437,9 @@ gtk_text_view_size_allocate (GtkWidget *widget, GdkRectangle right_rect; GdkRectangle top_rect; GdkRectangle bottom_rect; - + gint focus_edge_width; + gboolean interior_focus; + text_view = GTK_TEXT_VIEW (widget); DV(g_print(G_STRLOC"\n")); @@ -2448,7 +2457,14 @@ gtk_text_view_size_allocate (GtkWidget *widget, * windows get at least a 1x1 allocation. */ - width = allocation->width - FOCUS_EDGE_WIDTH * 2; + gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL); + + if (interior_focus) + focus_edge_width = 0; + else + focus_edge_width = 1; + + width = allocation->width - focus_edge_width * 2; if (text_view->left_window) left_rect.width = text_view->left_window->requisition.width; @@ -2470,7 +2486,7 @@ gtk_text_view_size_allocate (GtkWidget *widget, bottom_rect.width = text_rect.width; - height = allocation->height - FOCUS_EDGE_WIDTH * 2; + height = allocation->height - focus_edge_width * 2; if (text_view->top_window) top_rect.height = text_view->top_window->requisition.height; @@ -2492,8 +2508,8 @@ gtk_text_view_size_allocate (GtkWidget *widget, right_rect.height = text_rect.height; /* Origins */ - left_rect.x = FOCUS_EDGE_WIDTH; - top_rect.y = FOCUS_EDGE_WIDTH; + left_rect.x = focus_edge_width; + top_rect.y = focus_edge_width; text_rect.x = left_rect.x + left_rect.width; text_rect.y = top_rect.y + top_rect.height; @@ -3465,10 +3481,15 @@ gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event) static void gtk_text_view_draw_focus (GtkWidget *widget) { + gboolean interior_focus; + + /* We clear the focus if we are in interior focus mode. */ + gtk_widget_style_get (widget, "interior_focus", &interior_focus, NULL); + if (GTK_WIDGET_DRAWABLE (widget)) { - if (GTK_WIDGET_HAS_FOCUS (widget)) - { + if (GTK_WIDGET_HAS_FOCUS (widget) && !interior_focus) + { gtk_paint_focus (widget->style, widget->window, NULL, widget, "textview", 0, 0, @@ -5537,16 +5558,26 @@ buffer_to_widget (GtkTextView *text_view, gint *window_x, gint *window_y) { + gint focus_edge_width; + gboolean interior_focus; + + gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL); + + if (interior_focus) + focus_edge_width = 0; + else + focus_edge_width = 1; + if (window_x) { - *window_x = buffer_x - text_view->xoffset + FOCUS_EDGE_WIDTH; + *window_x = buffer_x - text_view->xoffset + focus_edge_width; if (text_view->left_window) *window_x += text_view->left_window->allocation.width; } if (window_y) { - *window_y = buffer_y - text_view->yoffset + FOCUS_EDGE_WIDTH; + *window_y = buffer_y - text_view->yoffset + focus_edge_width; if (text_view->top_window) *window_y += text_view->top_window->allocation.height; } @@ -5674,16 +5705,26 @@ widget_to_buffer (GtkTextView *text_view, gint *buffer_x, gint *buffer_y) { + gint focus_edge_width; + gboolean interior_focus; + + gtk_widget_style_get (GTK_WIDGET (text_view), "interior_focus", &interior_focus, NULL); + + if (interior_focus) + focus_edge_width = 0; + else + focus_edge_width = 1; + if (buffer_x) { - *buffer_x = widget_x - FOCUS_EDGE_WIDTH + text_view->xoffset; + *buffer_x = widget_x - focus_edge_width + text_view->xoffset; if (text_view->left_window) *buffer_x -= text_view->left_window->allocation.width; } if (buffer_y) { - *buffer_y = widget_y - FOCUS_EDGE_WIDTH + text_view->yoffset; + *buffer_y = widget_y - focus_edge_width + text_view->yoffset; if (text_view->top_window) *buffer_y -= text_view->top_window->allocation.height; } diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index ed8fb0b3b4..1008c0f0c0 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -35,11 +35,13 @@ #include "gtkstock.h" #include "gtkiconfactory.h" #include "gtkimage.h" +#include "gtksettings.h" #include "gtkintl.h" +#define DEFAULT_IPADDING 0 #define DEFAULT_SPACE_SIZE 5 -#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_EMPTY +#define DEFAULT_SPACE_STYLE GTK_TOOLBAR_SPACE_LINE #define DEFAULT_ICON_SIZE GTK_ICON_SIZE_LARGE_TOOLBAR @@ -69,6 +71,7 @@ struct _GtkToolbarChildSpace static void gtk_toolbar_class_init (GtkToolbarClass *class); static void gtk_toolbar_init (GtkToolbar *toolbar); +static void gtk_toolbar_finalize (GObject *object); static void gtk_toolbar_set_property (GObject *object, guint prop_id, const GValue *value, @@ -88,6 +91,7 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_toolbar_style_set (GtkWidget *widget, GtkStyle *prev_style); +static void gtk_toolbar_show_all (GtkWidget *widget); static void gtk_toolbar_add (GtkContainer *container, GtkWidget *widget); static void gtk_toolbar_remove (GtkContainer *container, @@ -174,6 +178,8 @@ gtk_toolbar_class_init (GtkToolbarClass *class) container_class = (GtkContainerClass *) class; parent_class = gtk_type_class (gtk_container_get_type ()); + + gobject_class->finalize = gtk_toolbar_finalize; object_class->destroy = gtk_toolbar_destroy; gobject_class->set_property = gtk_toolbar_set_property; @@ -185,6 +191,7 @@ gtk_toolbar_class_init (GtkToolbarClass *class) widget_class->size_request = gtk_toolbar_size_request; widget_class->size_allocate = gtk_toolbar_size_allocate; widget_class->style_set = gtk_toolbar_style_set; + widget_class->show_all = gtk_toolbar_show_all; container_class->add = gtk_toolbar_add; container_class->remove = gtk_toolbar_remove; @@ -238,6 +245,16 @@ gtk_toolbar_class_init (GtkToolbarClass *class) G_MAXINT, DEFAULT_SPACE_SIZE, G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_int ("internal_padding", + _("Internal padding"), + _("Amount of border space between the toolbar shadow and the buttons"), + 0, + G_MAXINT, + DEFAULT_IPADDING, + G_PARAM_READABLE)); + gtk_widget_class_install_style_property (widget_class, g_param_spec_enum ("space_style", _("Space style"), @@ -252,8 +269,66 @@ gtk_toolbar_class_init (GtkToolbarClass *class) _("Button relief"), _("Type of bevel around toolbar buttons"), GTK_TYPE_RELIEF_STYLE, - GTK_RELIEF_NORMAL, + GTK_RELIEF_NONE, G_PARAM_READABLE)); + + gtk_widget_class_install_style_property (widget_class, + g_param_spec_enum ("shadow_type", + _("Shadow type"), + _("Style of bevel around the toolbar"), + GTK_TYPE_SHADOW_TYPE, + GTK_SHADOW_OUT, + G_PARAM_READABLE)); + + gtk_settings_install_property (gtk_settings_get_global (), + g_param_spec_enum ("gtk-toolbar-style", + _("Toolbar style"), + _("Whether default toolbars have text only, text and icons, icons only, etc."), + GTK_TYPE_TOOLBAR_STYLE, + GTK_TOOLBAR_BOTH, + G_PARAM_READWRITE)); + + gtk_settings_install_property (gtk_settings_get_global (), + g_param_spec_enum ("gtk-toolbar-icon-size", + _("Toolbar icon size"), + _("Size of icons in default toolbars"), + GTK_TYPE_ICON_SIZE, + GTK_ICON_SIZE_LARGE_TOOLBAR, + G_PARAM_READWRITE)); +} + +static void +style_change_notify (GObject *object, + GParamSpec *pspec, + gpointer data) +{ + GtkToolbar *toolbar; + + toolbar = GTK_TOOLBAR (data); + + if (!toolbar->style_set) + { + /* pretend it was set, then unset, thus reverting to new default */ + toolbar->style_set = TRUE; + gtk_toolbar_unset_style (toolbar); + } +} + +static void +icon_size_change_notify (GObject *object, + GParamSpec *pspec, + gpointer data) +{ + GtkToolbar *toolbar; + + toolbar = GTK_TOOLBAR (data); + + if (!toolbar->icon_size_set) + { + /* pretend it was set, then unset, thus reverting to new default */ + toolbar->icon_size_set = TRUE; + gtk_toolbar_unset_icon_size (toolbar); + } } static void @@ -265,11 +340,46 @@ gtk_toolbar_init (GtkToolbar *toolbar) toolbar->num_children = 0; toolbar->children = NULL; toolbar->orientation = GTK_ORIENTATION_HORIZONTAL; - toolbar->style = GTK_TOOLBAR_ICONS; toolbar->icon_size = DEFAULT_ICON_SIZE; toolbar->tooltips = gtk_tooltips_new (); toolbar->button_maxw = 0; toolbar->button_maxh = 0; + + toolbar->style_set = FALSE; + toolbar->icon_size_set = FALSE; + g_object_get (gtk_settings_get_global (), + "gtk-toolbar-icon-size", + &toolbar->icon_size, + "gtk-toolbar-style", + &toolbar->style, + NULL); + + toolbar->style_set_connection = + g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()), + "notify::gtk-toolbar-style", + G_CALLBACK (style_change_notify), + toolbar, NULL, FALSE, FALSE); + + toolbar->icon_size_connection = + g_signal_connect_data (G_OBJECT (gtk_settings_get_global ()), + "notify::gtk-toolbar-icon-size", + G_CALLBACK (icon_size_change_notify), + toolbar, NULL, FALSE, FALSE); +} + +static void +gtk_toolbar_finalize (GObject *object) +{ + GtkToolbar *toolbar; + + toolbar = GTK_TOOLBAR (object); + + g_signal_handler_disconnect (G_OBJECT (gtk_settings_get_global ()), + toolbar->style_set_connection); + g_signal_handler_disconnect (G_OBJECT (gtk_settings_get_global ()), + toolbar->icon_size_connection); + + G_OBJECT_CLASS (parent_class)->finalize (object); } static void @@ -314,16 +424,12 @@ gtk_toolbar_get_property (GObject *object, } GtkWidget* -gtk_toolbar_new (GtkOrientation orientation, - GtkToolbarStyle style) +gtk_toolbar_new (void) { GtkToolbar *toolbar; toolbar = gtk_type_new (gtk_toolbar_get_type ()); - toolbar->orientation = orientation; - toolbar->style = style; - return GTK_WIDGET (toolbar); } @@ -462,15 +568,32 @@ gtk_toolbar_expose (GtkWidget *widget, GtkToolbar *toolbar; GList *children; GtkToolbarChild *child; + gint border_width; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_TOOLBAR (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); + border_width = GTK_CONTAINER (widget)->border_width; + if (GTK_WIDGET_DRAWABLE (widget)) { + GtkShadowType shadow_type; + toolbar = GTK_TOOLBAR (widget); + gtk_widget_style_get (widget, "shadow_type", &shadow_type, NULL); + + gtk_paint_box (widget->style, + widget->window, + GTK_WIDGET_STATE (widget), + shadow_type, + &event->area, widget, "toolbar", + widget->allocation.x + border_width, + widget->allocation.y + border_width, + widget->allocation.width - border_width, + widget->allocation.height - border_width); + for (children = toolbar->children; children; children = children->next) { child = children->data; @@ -502,6 +625,7 @@ gtk_toolbar_size_request (GtkWidget *widget, gint widget_maxw, widget_maxh; GtkRequisition child_requisition; gint space_size; + gint ipadding; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TOOLBAR (widget)); @@ -579,6 +703,12 @@ gtk_toolbar_size_request (GtkWidget *widget, requisition->height += nbuttons * button_maxh; } + /* Extra spacing */ + gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL); + + requisition->width += 2 * (widget->style->xthickness + ipadding); + requisition->height += 2 * (widget->style->ythickness + ipadding); + toolbar->button_maxw = button_maxw; toolbar->button_maxh = button_maxh; } @@ -593,22 +723,29 @@ gtk_toolbar_size_allocate (GtkWidget *widget, GtkToolbarChildSpace *child_space; GtkAllocation alloc; GtkRequisition child_requisition; - gint border_width; + gint x_border_width, y_border_width; gint space_size; - + gint ipadding; + g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_TOOLBAR (widget)); g_return_if_fail (allocation != NULL); toolbar = GTK_TOOLBAR (widget); widget->allocation = *allocation; + + x_border_width = GTK_CONTAINER (toolbar)->border_width; + y_border_width = GTK_CONTAINER (toolbar)->border_width; - border_width = GTK_CONTAINER (toolbar)->border_width; - + gtk_widget_style_get (widget, "internal_padding", &ipadding, NULL); + + x_border_width += 2 * (widget->style->xthickness + ipadding); + y_border_width += 2 * (widget->style->ythickness + ipadding); + if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL) - alloc.x = allocation->x + border_width; + alloc.x = allocation->x + x_border_width; else - alloc.y = allocation->y + border_width; + alloc.y = allocation->y + y_border_width; space_size = get_space_size (toolbar); @@ -697,6 +834,26 @@ gtk_toolbar_style_set (GtkWidget *widget, gtk_toolbar_update_button_relief (GTK_TOOLBAR (widget)); } +static void +child_show_all (GtkWidget *widget) +{ + /* Don't show our own children, since that would + * show labels we may intend to hide in icons-only mode + */ + if (!g_object_get_data (G_OBJECT (widget), + "gtk-toolbar-is-child")) + gtk_widget_show_all (widget); +} + +static void +gtk_toolbar_show_all (GtkWidget *widget) +{ + gtk_container_foreach (GTK_CONTAINER (widget), + (GtkCallback) child_show_all, + NULL); + gtk_widget_show (widget); +} + static void gtk_toolbar_add (GtkContainer *container, GtkWidget *widget) @@ -844,7 +1001,8 @@ gtk_toolbar_insert_item (GtkToolbar *toolbar, * * This function sets the size of stock icons in the toolbar. You * can call it both before you add the icons and after they've been - * added. + * added. The size you set will override user preferences for the default + * icon size. **/ void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, @@ -858,6 +1016,8 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar, g_return_if_fail (toolbar != NULL); g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); + toolbar->icon_size_set = TRUE; + if (toolbar->icon_size == icon_size) return; @@ -885,6 +1045,31 @@ gtk_toolbar_set_icon_size (GtkToolbar *toolbar, gtk_widget_queue_resize (GTK_WIDGET (toolbar)); } +/** + * gtk_toolbar_unset_icon_size: + * @toolbar: a #GtkToolbar + * + * Unsets toolbar icon size set with gtk_toolbar_set_icon_size(), so that + * user preferences will be used to determine the icon size. + **/ +void +gtk_toolbar_unset_icon_size (GtkToolbar *toolbar) +{ + GtkIconSize size; + + if (toolbar->icon_size_set) + { + g_object_get (gtk_settings_get_global (), + "gtk-toolbar-icon-size", + &size, NULL); + + if (size != toolbar->icon_size) + gtk_toolbar_set_icon_size (toolbar, size); + + toolbar->icon_size_set = FALSE; + } +} + /** * gtk_toolbar_insert_stock: * @toolbar: A #GtkToolbar @@ -1178,6 +1363,13 @@ gtk_toolbar_internal_insert_element (GtkToolbar *toolbar, gtk_widget_show (child->icon); } + if (type != GTK_TOOLBAR_CHILD_WIDGET) + { + /* Mark child as ours */ + g_object_set_data (G_OBJECT (child->widget), + "gtk-toolbar-is-child", + GINT_TO_POINTER (TRUE)); + } gtk_widget_show (child->widget); break; @@ -1217,7 +1409,6 @@ void gtk_toolbar_set_orientation (GtkToolbar *toolbar, GtkOrientation orientation) { - g_return_if_fail (toolbar != NULL); g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[ORIENTATION_CHANGED], orientation); @@ -1227,12 +1418,40 @@ void gtk_toolbar_set_style (GtkToolbar *toolbar, GtkToolbarStyle style) { - g_return_if_fail (toolbar != NULL); g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); + toolbar->style_set = TRUE; gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[STYLE_CHANGED], style); } +/** + * gtk_toolbar_unset_style: + * @toolbar: a #GtkToolbar + * + * Unsets a toolbar style set with gtk_toolbar_set_style(), so that + * user preferences will be used to determine the toolbar style. + **/ +void +gtk_toolbar_unset_style (GtkToolbar *toolbar) +{ + GtkToolbarStyle style; + + g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); + + if (toolbar->style_set) + { + g_object_get (gtk_settings_get_global (), + "gtk-toolbar-style", + &style, + NULL); + + if (style != toolbar->style) + gtk_signal_emit (GTK_OBJECT (toolbar), toolbar_signals[STYLE_CHANGED], style); + + toolbar->style_set = FALSE; + } +} + void gtk_toolbar_set_tooltips (GtkToolbar *toolbar, gboolean enable) @@ -1290,7 +1509,7 @@ gtk_real_toolbar_style_changed (GtkToolbar *toolbar, GList *children; GtkToolbarChild *child; GtkWidget* box = NULL; - + g_return_if_fail (toolbar != NULL); g_return_if_fail (GTK_IS_TOOLBAR (toolbar)); diff --git a/gtk/gtktoolbar.h b/gtk/gtktoolbar.h index 19ed1b90c4..79d3d79dbc 100644 --- a/gtk/gtktoolbar.h +++ b/gtk/gtktoolbar.h @@ -91,6 +91,12 @@ struct _GtkToolbar gint button_maxw; gint button_maxh; + + guint style_set_connection; + guint icon_size_connection; + + guint style_set : 1; + guint icon_size_set : 1; }; struct _GtkToolbarClass @@ -105,8 +111,7 @@ struct _GtkToolbarClass GtkType gtk_toolbar_get_type (void) G_GNUC_CONST; -GtkWidget* gtk_toolbar_new (GtkOrientation orientation, - GtkToolbarStyle style); +GtkWidget* gtk_toolbar_new (void); /* Simple button items */ GtkWidget* gtk_toolbar_append_item (GtkToolbar *toolbar, @@ -133,8 +138,6 @@ GtkWidget* gtk_toolbar_insert_item (GtkToolbar *toolbar, gint position); /* Stock Items */ -void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, - GtkIconSize icon_size); GtkWidget* gtk_toolbar_insert_stock (GtkToolbar *toolbar, const gchar *stock_id, const char *tooltip_text, @@ -203,8 +206,12 @@ void gtk_toolbar_set_orientation (GtkToolbar *toolbar, GtkOrientation orientation); void gtk_toolbar_set_style (GtkToolbar *toolbar, GtkToolbarStyle style); +void gtk_toolbar_set_icon_size (GtkToolbar *toolbar, + GtkIconSize icon_size); void gtk_toolbar_set_tooltips (GtkToolbar *toolbar, gboolean enable); +void gtk_toolbar_unset_style (GtkToolbar *toolbar); +void gtk_toolbar_unset_icon_size (GtkToolbar *toolbar); #ifdef __cplusplus } diff --git a/tests/testgtk.c b/tests/testgtk.c index 193087613b..956392ae48 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -724,7 +724,7 @@ create_toolbar (void) gtk_container_set_border_width (GTK_CONTAINER (window), 0); gtk_widget_realize (window); - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); + toolbar = gtk_toolbar_new (); gtk_toolbar_insert_stock (GTK_TOOLBAR (toolbar), GTK_STOCK_NEW, @@ -825,7 +825,7 @@ make_toolbar (GtkWidget *window) if (!GTK_WIDGET_REALIZED (window)) gtk_widget_realize (window); - toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); + toolbar = gtk_toolbar_new (); gtk_toolbar_append_item (GTK_TOOLBAR (toolbar), "Horizontal", "Horizontal toolbar layout", NULL, -- 2.30.2